import type { ElementHiderRuleConfig } from '../../../types/constants'
import { ElementSelectorPosition, ElementSelectorType } from '../../../types/constants'
import { ELEMENT_IDENTIFIER_CONFIG } from '../../service/element_identifier/types'

export const JIAN_SHU_WEB_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.default.header.id]: {
    hide: true,
    selectorType: ElementSelectorType.Tag,
    selector: 'header',
    position: ElementSelectorPosition.TopCenter,
    effectToc: true,
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.leftAside.id]: {
    hide: true,
    selectorType: ElementSelectorType.Complex,
    selector: 'div:has(> div > div[aria-label=\'赞赏作者\'])',
    position: ElementSelectorPosition.MiddleLeft,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.articleHr.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: 'article hr',
    position: ElementSelectorPosition.MiddleCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.bottomInfo.id]: {
    show: false,
    hide: true,
    selectorType: ElementSelectorType.JQuery,
    selector: 'section div:has(button span:contains(赞赏支持))',
    position: ElementSelectorPosition.MiddleCenter,
    listen: true,
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.rightAside.id]: {
    hide: true,
    selectorType: ElementSelectorType.Tag,
    selector: 'aside',
    position: ElementSelectorPosition.MiddleRight,
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.pageSeparator.id]: {
    hide: true,
    selectorType: ElementSelectorType.Attribute,
    selector: '[data-page-element=\'page-separator\']',
    position: ElementSelectorPosition.BottomCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.authorInfo.id]: {
    hide: true,
    selectorType: ElementSelectorType.JQuery,
    selector: 'section div:has(div span:contains(总资产)):has(button span:contains(关注))',
    position: ElementSelectorPosition.BottomCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.ad.contentAd.id]: {
    hide: true,
    selectorType: ElementSelectorType.Class,
    selector: '.adad_container',
    position: ElementSelectorPosition.BottomCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.ad.baiduAd.id]: {
    hide: true,
    selectorType: ElementSelectorType.Attribute,
    selector: '[aria-label=\'baidu-ad\']',
    position: ElementSelectorPosition.BottomCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.articleComment.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#note-page-comment',
    position: ElementSelectorPosition.BottomCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.specialIncome.id]: {
    hide: true,
    selectorType: ElementSelectorType.JQuery,
    selector: 'div:has(> h3 > span:contains(专题收入))',
    position: ElementSelectorPosition.BottomCenter,
    listen: true,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.recommendRead.id]: {
    hide: true,
    selectorType: ElementSelectorType.JQuery,
    selector: 'div:has(> h3 > span:contains(推荐阅读))',
    position: ElementSelectorPosition.BottomCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: true,
    selectorType: ElementSelectorType.Tag,
    selector: 'footer',
    position: ElementSelectorPosition.BottomCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.backTop.id]: {
    hide: true,
    selectorType: ElementSelectorType.Complex,
    selector: '#__next > div .ant-back-top',
    position: ElementSelectorPosition.BottomRight,
  },
}
